//
//  FeedBackVC.m
//  MyProject
//
//  Created by jiaming yan on 2018/5/17.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "FeedBackVC.h"
#import "IQTextView.h"

@interface FeedBackVC ()
@property (weak, nonatomic) IBOutlet IQTextView *contentTextView;

@end

@implementation FeedBackVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"意见反馈";
    self.contentTextView.placeholder = @"请输入您要反馈的内容";
    self.view.backgroundColor = UIColorFromRGB(0XF2F4F5);
    [self rightButton];
}
-(void)rightButton{
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 0, 100, 44);
//    [backBtn setImage:IMAGE(@"ic_problem") forState:UIControlStateNormal];
    [backBtn setTitle:@"确认" forState:UIControlStateNormal];
    [backBtn setTitleColor:UIColorFromRGB(0X1EB0C1) forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(rightButtonClick) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
                                       initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                       target:nil action:nil];
    negativeSpacer.width = -20;
    self.navigationItem.rightBarButtonItems = @[negativeSpacer,backItem];
    
    if (IOS11Later) {
        backBtn.contentHorizontalAlignment =UIControlContentHorizontalAlignmentRight;
    }
}
-(void)rightButtonClick{
    if (self.contentTextView.text.length == 0) {
        ALERT_VIEW(@"请输入反馈内容");
        return;
    }
    [self showProgressWithView:self.view animated:YES];
    [YJMSendRequest postDataWithParameters:@{@"feedback":self.contentTextView.text} url:@"common/coupleBack" result:^(NSDictionary *result, NSError *error) {
        result = [CommonUtils decryptDicWithResult:result];
        [self hideProgress:self.view animated:YES];
        if([result[@"result"] integerValue] == 1)
        {
           [CommonUtils showToast:@"反馈成功"];
            
        }else{
            [CommonUtils showToast:[result objectForKey:@"msg"]];
        }
        [self.navigationController popViewControllerAnimated:YES];
        
    }];
    
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
